Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/6 fastify plugin #49

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open

Conversation

abrl91
Copy link

@abrl91 abrl91 commented Dec 11, 2024

Issue: #6
Added a Fastify plugin to complement the existing Express middleware and NestJS guard.

The plugin:

  1. Checks if a request is allowed based on the user's plan limits
  2. Returns 402 (Payment Required) if the request exceeds limits
  3. Tracks usage by incrementing counters after successful requests

Usage:

import { priciPlugin } from '@prici/sdk/fastify';

await fastify.register(priciPlugin, {
  sdk: priciSdk,
  fieldId: 'api-calls'
});

Copy link

netlify bot commented Dec 11, 2024

Deploy Preview for dashing-meerkat-19c0fa ready!

Name Link
🔨 Latest commit 041c0b7
🔍 Latest deploy log https://app.netlify.com/sites/dashing-meerkat-19c0fa/deploys/675c27a4291879000854f2d5
😎 Deploy Preview https://deploy-preview-49--dashing-meerkat-19c0fa.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@@ -17,6 +17,8 @@
"license": "MIT",
"dependencies": {
"@prici/shared-remult": "workspace:^",
"fastify": "^4.26.0",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fastify should be a peer + peer meta like nest.js (looks at lines 24-31).

@abrl91 abrl91 force-pushed the feat/6-fastify-plugin branch from 1c0a591 to caac286 Compare December 12, 2024 16:54
@abrl91 abrl91 requested a review from davidmeirlevy December 12, 2024 16:55
@davidmeirlevy
Copy link
Contributor

Update the pnpm lock to pass the tests.

@abrl91
Copy link
Author

abrl91 commented Dec 13, 2024

@davidmeirlevy I wrote unit tests but when I run them (or any other tests) it fails with some jest error and module loader.

@davidmeirlevy
Copy link
Contributor

There's no jest in this project.
It's node native test runner.

@abrl91
Copy link
Author

abrl91 commented Dec 13, 2024

There's no jest in this project. It's node native test runner.

OK! That makes sense! because I ran it using the jest extension 😅
I ran it from the package json script and it worked.

@abrl91
Copy link
Author

abrl91 commented Dec 13, 2024

pnpm build still doesn't work and I don't understand why

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants